gusucode.com > VC++ 汽配销售管理系统(Access)源码程序 > VC++ 汽配销售管理系统(Access)源码程序/源码/DLOGIN.cpp
//Download by http://www.NewXing.com // DLOGIN.cpp : implementation file // #include "stdafx.h" #include "qpglxt.h" #include "DLOGIN.h" #include "DMain.h" #include "RxRecordset.h" #ifdef _DEBUG #define new DEBUG_NEW #undef THIS_FILE static char THIS_FILE[] = __FILE__; #endif extern CQpglxtApp theApp; ///////////////////////////////////////////////////////////////////////////// // CDLOGIN dialog CDLOGIN::CDLOGIN(CWnd* pParent /*=NULL*/) : CDialog(CDLOGIN::IDD, pParent) { //{{AFX_DATA_INIT(CDLOGIN) // NOTE: the ClassWizard will add member initialization here //}}AFX_DATA_INIT nTryTime=1; } void CDLOGIN::DoDataExchange(CDataExchange* pDX) { CDialog::DoDataExchange(pDX); //{{AFX_DATA_MAP(CDLOGIN) DDX_Control(pDX, ID_LOG_EDTPWD, m_EdtPwd); DDX_Control(pDX, ID_LOG_COMNAME, m_ComName); DDX_Control(pDX, ID_LOG_BUTLOGIN, m_ButLogin); DDX_Control(pDX, ID_LOG_BUTEXIT, m_ButExit); //}}AFX_DATA_MAP } BEGIN_MESSAGE_MAP(CDLOGIN, CDialog) //{{AFX_MSG_MAP(CDLOGIN) ON_BN_CLICKED(ID_LOG_BUTLOGIN, OnLogButlogin) ON_BN_CLICKED(ID_LOG_BUTEXIT, OnLogButexit) //}}AFX_MSG_MAP END_MESSAGE_MAP() ///////////////////////////////////////////////////////////////////////////// // CDLOGIN message handlers void CDLOGIN::OnOK() { // TODO: Add extra validation here //CDialog::OnOK(); } BOOL CDLOGIN::OnInitDialog() { CDialog::OnInitDialog(); rst.Open("操作员信息表"); if(rst.GetRecordCount()<1) { this->OnCancel(); OP="无操作员"; CDMain dlg; dlg.DoModal(); } else m_ComName.SetRecordset(rst,"用户名"); return TRUE; // return TRUE unless you set the focus to a control // EXCEPTION: OCX Property Pages should return FALSE } void CDLOGIN::OnLogButlogin() { CString sSQL,sPwd,sOldPwd,sUserName; m_EdtPwd.GetWindowText(sPwd); if(nTryTime>=3) { MessageBox("对不起!您不能登录本系统,请与管理员联系!","系统提示",MB_OK|MB_ICONSTOP); this->OnCancel(); return; } m_ComName.GetWindowText(sUserName); sOldPwd=ado.FieldToOtherField("操作员信息表","用户名",sUserName,"密码",1); if(sOldPwd.IsEmpty()) { MessageBox("您输入的用户不存在!请重新的输入!","系统提示",MB_OK|MB_ICONSTOP); m_ComName.SetFocus(); nTryTime=nTryTime+1; return; } if(sOldPwd==sPwd) { this->OnCancel(); CDMain dlg; OP=sUserName; dlg.DoModal(); } else { MessageBox("您输入的密码不正确!请重试!","系统提示",MB_OK|MB_ICONSTOP); m_EdtPwd.SetWindowText(""); m_EdtPwd.SetFocus(); nTryTime=nTryTime+1; } } void CDLOGIN::OnLogButexit() { this->OnCancel(); }